﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Chowpoo.Sql;

namespace CourseSystem.Core.Entities
{

    [Table(Name = "ExaminationItem")]
    public class ExaminationItemInfo : IDetach
    {
        public ExaminationItemInfo()
        {
            Detach();
        }
        #region Model
        private int _id;
        private int _eid = 0;
        private int _qid = 0;


        private EntityRef<QuestionLibInfo> _questionLibInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_questionLibInfo", ThisKey = "Qid", OtherKey = "Id", IsForeignKey = true)]
        [XmlIgnore]
        public QuestionLibInfo QuestionLibInfo
        {
            get { return _questionLibInfo.Entity; }
            set { _questionLibInfo.Entity = value; }
        }

        private EntityRef<ExaminationInfo> _examinationInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_examinationInfo", ThisKey = "Eid", OtherKey = "Id", IsForeignKey = true)]
        [XmlIgnore]
        public ExaminationInfo ExaminationInfo
        {
            get { return _examinationInfo.Entity; }
            set { _examinationInfo.Entity = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        [Column(IsDbGenerated = true, IsPrimaryKey = true, IsVersion = true)]
        public int Id
        {
            set { _id = value; }
            get { return _id; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int Eid
        {
            set { _eid = value; }
            get { return _eid; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int Qid
        {
            set { _qid = value; }
            get { return _qid; }
        }
        #endregion Model

        public void Detach()
        {
            _questionLibInfo = default(EntityRef<QuestionLibInfo>);
            _examinationInfo = default(EntityRef<ExaminationInfo>);
        }
    }
}
